import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/views/Layout')
const Home = () => import('@/views/Home')
const Goods = () => import('@/views/Goods')
const Login = () => import('@/views/Login')
const Cart = () => import('@/views/Cart')
const Settlement = () => import('@/views/Member/settlement')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/goods/:id',
        component: Goods
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/settlement',
        component: Settlement
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]
// 创建路由实例
const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则，写法和之前一样
  routes,
  // 返回时回到最顶端,最左侧
  scrollBehavior () {
    return { left: 0, top: 0 }
  }
})

export default router
